package com.example.demo.service;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.example.demo.dao.BookDao;
import com.example.demo.entity.Book;
import com.example.demo.repository.BookRepository;

@Service
public class BookService {

	@Resource
	private BookRepository bookRepository;
	
	@Resource
	private BookDao bookDao;
	
	
	@Transactional
	public Book insertBook(Book book) {
		return bookRepository.save(book);
	}

	public Book getById(int i) {
//		return bookRepository.getOne(i);
		return bookDao.getOne();
	}
	
	
	public List<Book> getAll() {
//		return bookRepository.getAll();
		return bookDao.getBookAll();
	}
	
	public List<Book> getByName(String name) {
		return bookRepository.getByName(name);
	}
}
